package cn.bdqn.controller;

import cn.bdqn.pojo.User;
import cn.bdqn.service.UserService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

/**
 * @author 朱坤昊
 * @create 2021-03-13 17:26
 */
@Controller
public class UserController {
    @Resource
    private UserService userService;

    /*登录*/
    @RequestMapping("/gologin")
    public String gologin(){
        return "system/main/login";
    }
     @RequestMapping("/login")
    public String login(String loginname, String pwd, HttpServletRequest request, HttpSession session) {
         User user = userService.login(loginname, pwd);

         if (user != null) {

             session.setAttribute("user", user);
             System.out.printf(user.getLoginname());
             return "system/main/index";
         }
         request.setAttribute("tips", "账号或密码错误");
         return "system/main/login";
     }
    @RequestMapping("/goindex")
    public String goindex(){
        return "system/main/index";
    }
    @RequestMapping("/godesk")
    public String godesk(){
        return "system/main/deskManager";
    }

}
